package library.and.xps.com.step.view.activity;

import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import library.and.xps.com.step.R;
import library.and.xps.com.step.view.base.BaseActivity;

public class SetupUserNickameActivity extends BaseActivity {
    TextView tv_actionbar_right;
    EditText et_nickname;
    public static final int RESPONCECODE_CUSTOM_NICKNAME = 2;
    @Override
    protected int getLayout() {
        return R.layout.setup_nickname;
    }

    @Override
    protected void setData() {
        Intent i = getIntent();
        String nickname = i.getStringExtra("nickname");

        et_nickname.setText(nickname+"");
        et_nickname.setSelection(et_nickname.getText().length());
    }

    @Override
    protected void init() {
        et_nickname = r2v(R.id.et_pass);
        tv_actionbar_right = r2v(R.id.actionbar_tv_right);
        tv_actionbar_right.setVisibility(View.VISIBLE);
        tv_actionbar_right.setOnClickListener(this);
        tv_actionbar_right.setText("完成");
        r2v(R.id.actionbar_iv_back).setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        super.onClick(view);
        switch (view.getId()) {
            case R.id.actionbar_tv_right:
                String nickname = et_nickname.getText().toString();
                if(TextUtils.isEmpty(nickname))break;

                Intent i = new Intent();
                i.putExtra("nickname", nickname);
                setResult(RESPONCECODE_CUSTOM_NICKNAME,i);
                finish();
                break;
            case R.id.actionbar_iv_back:
                finish();
                break;
        }
    }
}
